<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%!
	public String toChinese(String input) {
		//System.out.print(input);
		try {
			return new String(input.getBytes("ISO-8859-1"), "utf-8");			
		} catch(Exception e) {
			return input;
		}
	}
%>
<%
// 	String studentNoKey = new String("studentNo");
	String studentNo = request.getParameter("studentNo");
	String realName = toChinese(request.getParameter("realName"));

	// 检测网页是否由新的访问用户
// 	if (session.isNew()){
// 		studentNo = request.getParameter(studentNoKey);
// 		session.setAttribute(studentNoKey, studentNo);
// 	} else {
// 		studentNo = (String)session.getAttribute(studentNoKey);
// 	}	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Check Info Page</title>
</head>
<body>
	<h3>您提交的注册信息如下：</h3>
	姓名：<%=studentNo %><br/>
	学号：<%=realName %><br/>
	性别：<%=toChinese(request.getParameter("gender")) %><br/>
	学历：<%=toChinese(request.getParameter("educational")) %><br/>
	爱好：<%
			String[] paramNames = request.getParameterValues("hobbit");
			//System.out.print(paramNames.toString());
			if(paramNames != null && paramNames.length > 0) {
			   for(int i=0;i<paramNames.length;i++) {
				   System.out.print(paramNames[i]);
			   	   out.print(String.format("%s ", toChinese(paramNames[i])));
			   }
		   }
		%><br/>
	专业：<%=toChinese(request.getParameter("special")) %><br/>
	
	<p>
		<span id="sec">5</span>秒后跳转到欢迎页面
		<%
			if(realName != null) { 
				session.setAttribute("realName", realName);
				session.setAttribute("studentNo", studentNo);
				response.setHeader("Refresh", "5;url=Welcome.jsp");
			}
		%>
	</p>
</body>
<script type="text/javascript">
	setInterval(function(){
		var sec = document.getElementById("sec");
		var count = parseInt(sec.innerText);
		
		if(count > 0) {
			sec.innerText = parseInt(sec.innerText) - 1;
		}
	}, 1000);
</script>
</html>